#ifndef __PROPERTY_WINDOW_H__
#define __PROPERTY_WINDOW_H__

#include <QHBoxLayout>
#include <kysdk/applications/knavigationbar.h>

#include "custom_widget.h"
#include "ukui_printer.h"
#include "size_para.h"
#include "property_list_window.h"
#include "property_itemwidget.h"
#include "select_ppd_dialog.h"

class PropertyWindow : public CustomWidget
{
    Q_OBJECT
public:
    explicit PropertyWindow(const UkuiUsbPrinter &printerInfo, QWidget *parent = nullptr);
    ~PropertyWindow();

    void onShow();
    void setQSSFontSize(QFont curFont);

private slots:
    void updatePPD(QString text);
    void selectPPDDialogShow();
    bool checkPrinterNameIsLegal(QString);
    void checkOptionConflicts(QString optionName, QString curVal);

private:
    std::unique_ptr<QHBoxLayout> m_leftLayout{nullptr};
    std::unique_ptr<QHBoxLayout> m_rightLayout{nullptr};
    std::unique_ptr<kdk::KNavigationBar> m_navigationBar{nullptr};
    std::unique_ptr<PropertyListWindow> m_propertyListWindow{nullptr};

    UkuiUsbPrinter m_currentPrinterInfo;

    void initUi();
    void initConnect();

    void addTab(const QString &name);

    void doSave();
    void insertItemListLayout();
    void updateItemListLayout(const UkuiUsbPrinter& printerInfo);
    void setAllConflicts(QString option, QMap<QString, QString> conflicts);
    void getZhPropertyfromEn(SelectableProperty& enProperty);
    std::unique_ptr<SelectPpdDialog> m_pSelectPPDDialog{nullptr};


    ProperytItemWidget *createItem(int index, PropertyBoxStyle style, const QString &propertyName);
    ProperytItemWidget *findItem(const QString &propertyName);

    std::unique_ptr<QMap<QString, ProperytItemWidget *> > m_itemMap{nullptr};
};
#endif // __PROPERTY_WINDOW_H__
